import { Modal, ModalProps } from '@arco-design/web-react'
import React from 'react'
import Import from './Import'

export interface IImportModalProps extends Omit<ModalProps, 'onOk'> {
    // 更新数据，导入成功后刷新一下当前分组
    onNeedUpdate?: () => void
}

const ImportModal: React.FC<IImportModalProps> = ({
    onCancel,
    onNeedUpdate,
    ...props
}) => {
    // 关闭后
    const handleCancel = () => {
        onCancel?.()
    }

    // 根据模式渲染表单

    return (
        <Modal
            title='导入'
            onCancel={handleCancel}
            footer={null}
            className='w-[800px]'
            unmountOnExit
            {...props}
        >
            <div className='max-h-[80vh] overflow-y-auto'>
                <Import
                    afterImported={() => {
                        onNeedUpdate?.()
                    }}
                />
            </div>
        </Modal>
    )
}

export default ImportModal
